#pragma comment(linker, "/STACK:16777216")

#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

char nota[12][3]={"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"};
int n, i, j, k, x;
string t;

queue<string> f;

bool read(){
	while(1){
		cin>>t;
		if(t=="***")return 0;
		
		if(( '0'<=t[0] && t[0]<='9') || t[0]=='-' ){
			n=atoi(t.c_str());
			return 1;
		}
		f.push(t);
	}
}

void process(){
	while(!f.empty()){
		t=f.front();
		f.pop();
		
		k=0;
		while(nota[k][0]!=t[0])k++;
		
		if(t[1]=='#')++k;
		else if(t[1]=='b')--k;
		
		if(n<0)x = (12+((k+n)%12))%12;
		else x = (k+n)%12;
		
		printf("%s ", nota[x] );
		
		t[0]=t[1]=t[2]='\0';
	}
	printf("\n");
}

int main(){ 
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	while(read())process();
	return 0;
}
